'use strict';

let querystring = require('querystring');
let http = require('http');
let util = require('./libs/util');
let cheerio = require('cheerio');

// 登录
const options1 = {
    hostname: '210.47.163.27',
    port: 9001,
    path: '/loginAction.do',
    method: 'POST',
    data: {
        'zjh': '账号', //账号密码记着替换
        'mm': '密码',
    }
};

util.ajax(options1, (res)=>{
    let cookie = res.headers['set-cookie'][0].slice(0, -8);
    // 课表
    const options2 = {
        hostname: '210.47.163.27',
        port: 9001,
        path: '/xkAction.do',
        method: 'GET',
        data: {
            'actionType': 6,
        },
        headers: {
            Cookie: cookie,
        },
        encoding: 'GBK'
    };
    util.ajax(options2, (res) => {
        // console.log(JSON.stringify(res.data));
        const $ = cheerio.load(res.data);
        console.log($('table#user.displayTag').text());
    }, (e) => {
        console.log(e);
    });
}, (e) => {
    console.log(e);
});
